package wire

import "fmt"

type Database interface {
	GetById(id string) map[string]interface{}
}

// ===== 模拟redis =====
var _ Database = (*RedisData)(nil)

type RedisData struct {
}

func NewRedisData() Database {
	fmt.Println("===== NewRedisData =====")
	return &RedisData{}
}

func (r *RedisData) GetById(id string) map[string]interface{} {
	fmt.Println("redis GetById " + id)
	return map[string]interface{}{
		"id":   id,
		"name": "redis",
	}
}

// ===== 模拟MySQL =====
var _ Database = (*MySqlData)(nil)

type MySqlData struct {
}

func NewMySqlData() Database {
	fmt.Println("===== NewMySqlData =====")
	return &MySqlData{}
}

func (r *MySqlData) GetById(id string) map[string]interface{} {
	fmt.Println("mysql GetById " + id)
	return map[string]interface{}{
		"id":   id,
		"name": "mysql",
	}
}
